#include "VertexShader.h"

#include <typeinfo>
#include "Utils.h"



VertexShader::VertexShader(Graphics& gfx, const std::string& path)
	:
	path(path)
{

	HR(D3DReadFileToBlob(ToWide("CompiledShader/"+path).c_str(), &pBytecodeBlob));
	HR(GetDevice(gfx)->CreateVertexShader(
		pBytecodeBlob->GetBufferPointer(),
		pBytecodeBlob->GetBufferSize(),
		nullptr,
		&pVertexShader
	));
}

void VertexShader::Bind(Graphics& gfx)
{
	(GetContext(gfx)->VSSetShader(pVertexShader.Get(), nullptr, 0u));
}

ID3DBlob* VertexShader::GetBytecode() const noexcept
{
	return pBytecodeBlob.Get();
}
std::shared_ptr<VertexShader> VertexShader::Create(Graphics& gfx, const std::string& path)
{
	return std::make_shared<VertexShader>(gfx, path);
}